﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight;
using Newtonsoft.Json;

namespace DeploymentTool.Model
{
    public class DepConfig : ViewModelBase
    {
        //public List<DepSearchPattern> SearchPatterns { get; set; }
        //public List<DepReplacePattern> ReplacePatterns { get; set; }

        public const string SearchPatternsPropertyName = "SearchPatterns";
        private List<DepSearchPattern> _searchPatterns = null;
        public List<DepSearchPattern> SearchPatterns
        {
            get
            {
                return _searchPatterns;
            }

            set
            {
                if (_searchPatterns == value)
                {
                    return;
                }

                RaisePropertyChanging(SearchPatternsPropertyName);
                _searchPatterns = value;
                RaisePropertyChanged(SearchPatternsPropertyName);
            }
        }

        public const string ReplacePatternsPropertyName = "ReplacePatterns";
        private List<DepReplacePattern> _replacePatterns = null;
        public List<DepReplacePattern> ReplacePatterns
        {
            get
            {
                return _replacePatterns;
            }

            set
            {
                if (_replacePatterns == value)
                {
                    return;
                }

                RaisePropertyChanging(ReplacePatternsPropertyName);
                _replacePatterns = value;
                RaisePropertyChanged(ReplacePatternsPropertyName);
            }
        }

        public const string IgnoredExtensionsPropertyName = "IgnoredExtensionsull";
        private List<string> _ignoredExtensions = null;
        public List<string> IgnoredExtensions
        {
            get
            {
                return _ignoredExtensions;
            }

            set
            {
                if (_ignoredExtensions == value)
                {
                    return;
                }

                RaisePropertyChanging(IgnoredExtensionsPropertyName);
                _ignoredExtensions = value;
                RaisePropertyChanged(IgnoredExtensionsPropertyName);
            }
        }

        public const string AcceptedExtensionsPropertyName = "AcceptedExtensions";
        private List<string> _acceptedExtensions = null;
        public List<string> AcceptedExtensions
        {
            get
            {
                return _acceptedExtensions;
            }

            set
            {
                if (_acceptedExtensions == value)
                {
                    return;
                }

                RaisePropertyChanging(AcceptedExtensionsPropertyName);
                _acceptedExtensions = value;
                RaisePropertyChanged(AcceptedExtensionsPropertyName);
            }
        }

        public string ToJsonString()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        public static DepConfig FromJson(string json)
        {
            return JsonConvert.DeserializeObject<DepConfig>(json);
        }
    }
}
